package cn.xyy.common.domain.system.auth;

import cn.xyy.common.annotation.jdbc.Columns;
import cn.xyy.common.annotation.jdbc.Tables;

import java.util.List;


/**
 * 数据字典表
 * @author xyy
 *
 */
@Tables("t_sys_dict")
public class Dict implements Comparable<Dict> {

    @Columns(value = "dict_id", primaryKey = true)
    private Integer id; // 字典id

    @Columns("dict_name")
    private String name;//

    @Columns("parent_id")
    private Integer parentId;

    @Columns("sorts")
    private Integer sorts;// 排序

    // 子
    private List<Dict> children;

    public boolean isRoot() {
        if (this.parentId == 0) {
            return true;
        }
        return false;
    }

    public Integer getId() {
        return id;
    }

    public Dict setId(Integer id) {
        this.id = id;
        return this;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public Integer getSorts() {
        return sorts;
    }

    public void setSorts(Integer sorts) {
        this.sorts = sorts;
    }

    public List<Dict> getChildren() {
        return children;
    }

    public void setChildren(List<Dict> children) {
        this.children = children;
    }

    @Override
    public int compareTo(Dict o) {
        if (this.getSorts() != null && o.getSorts() != null) {
            return this.getSorts().compareTo(o.getSorts());
        }
        return -1;
    }
}
